package com.ply.service.impl;

import com.ply.entity.vo.Result;
import com.ply.service.VisitUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class VisitUserServiceImpl implements VisitUserService {
    @Autowired
    ProjectServiceImpl projectService ;

    @Autowired
    UserServiceImpl userService;


    /**
     * 投票
     * @param optionId 选项id
     * @param ip 游客的ip
     * @return 成功或者失败
     */
    public Result<?> toVote(int optionId, String ip) {
        return projectService.toVote(optionId,ip);  //返回投票方法的结果

    }


    /**
     * 查询单个选项的投票记录
     * @param projectId 投票项目的id
     * @return
     */
    public Result<?> ViewRecord(int projectId) {
        Result list = projectService.selectProjectNameAndOptionNameAndSum(projectId);
        return Result.ok(list);
    }

}
